﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Python
{
    public class Field
    {
        protected static int _origRow;
        protected static int _origCol;
        protected int _x;
        protected int _y;

        public Field(int x0, int y0, int heght, int width)
        {
            _origRow = y0;
            _origCol = x0;
            _y = width;
            _x = heght;
            makeField(_x, _y);
        }
        protected void makeField(int x, int y)
        {
            // Clear the screen, then save the top and left coordinates.
            Console.Clear();
            _origRow = Console.CursorTop;
            _origCol = Console.CursorLeft;
            int yMax = y;
            int xMax = x;

            Depict DepictField = new Depict();       // Creation of a new object for arising of Field of this game.
            // Draw the left side of a xMax x yMax rectangle, from top to bottom.
            DepictField.WriteAt("+", 0, 0, _origCol,_origRow);
            for (int i = 1; i < yMax; i++)
            {
                DepictField.WriteAt("|", 0, i, _origCol, _origRow);
            }
            DepictField.WriteAt("+", 0, yMax - 1, _origCol, _origRow);

            // Draw the bottom side, from left to right.
            for (int i = 1; i < xMax; i++)
            {
                DepictField.WriteAt("-", i, yMax - 1, _origCol, _origRow);
            }

            DepictField.WriteAt("+", xMax - 1, yMax - 1, _origCol, _origRow);

            // Draw the right side, from bottom to top.
            DepictField.WriteAt("+", xMax - 1, 0, _origCol, _origRow);
            for (int i = 1; i < yMax - 1; i++)
            {
                DepictField.WriteAt("|", xMax - 1, i, _origCol, _origRow);
            }

            // Draw the top side, from right to left.
            for (int i = 1; i < xMax - 1; i++)
            {
                DepictField.WriteAt("-", i, 0, _origCol, _origRow);
            }
            Console.SetCursorPosition(0, 0);  // set cursor to start coordinates
        }
    }
}
